﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Framework.Packets;
using System.Net.Sockets;
using System.Threading;

namespace Framework.Networking
{
    /// <summary>
    /// Interface for a simple stream handling.
    /// </summary>
    public interface IStream
    {
        /// <summary>
        /// The socket we're streaming.
        /// </summary>
        Socket StreamSocket { get; }

        /// <summary>
        /// 
        /// </summary>
        byte[] Buffer { get; }

        /// <summary>
        /// 
        /// </summary>
        ManualResetEvent TimeoutTimer { get; }

        /// <summary>
        /// Start accepting connections.
        /// </summary>
        void Start();

        /// <summary>
        /// Stop accepting connections.
        /// </summary>
        void Stop();

        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        void Send(IPacket packet);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        void Send(byte[] packet);

        /// <summary>
        /// 
        /// </summary>
        /// <param name="packet"></param>
        void Send(PacketWriter packet);

        /// <summary>
        /// Checks if interface and port if free for listening.
        /// </summary>
        /// <returns>true if interface and port is free</returns>
        //bool PortAvailable();

        /// <summary>
        /// Action on for traffic handling.
        /// </summary>
        /// <param name="ar"></param>
        ///void OnAccept(IAsyncResult ar);
    }
}
